package org.example.hansp.sort;

import java.util.Arrays;
import java.util.Comparator;

public class BubbleSortPro01 {
    public static void main(String[] args) {
        int[] arr = { 3,0,-1,9,6};
//        int[] arr={2,-1,8,6,9,99};
         bubbleSort(arr,new Comparator<Integer>() {
             @Override
             public int compare(Integer o1, Integer o2) {
                 return o1-o2;
             }

        });
        System.out.println(Arrays.toString(arr));
    }
    public static void bubbleSort(int[] array, Comparator<Integer> comp) {
        for(int i=0;i<array.length-1;i++){
            for(int j=i+1;j<array.length;j++){
                if(comp.compare(array[i],array[j])>0){
                    int temp = array[i];
                    array[i] = array[j];
                    array[j] = temp;
                }
            }

        }

    }
}
